#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>

/*Test reGreathall. This function checks */
int main(){

  struct gameState state;
  int post;
  int pre;
  int n;
  int gameEnd;
  int fail;
  int ret;
  int i;
  int p;
  srand(time(NULL));


  printf("Testing Great Hall Card\n");
  for (n = 0; n < 2000; n++) {
    for (i = 0; i < sizeof(struct gameState); i++) {
      ((char*)&state)[i] = floor(rand() * 256);
    }
    p = rand() % 2;
    printf("Player num %d\n", p);
    //TODO set player
    state.numPlayers = 2;
    state.deckCount[p] = rand() % MAX_DECK;
    state.discardCount[p] = rand() % MAX_DECK;
    state.handCount[p] = rand() % MAX_HAND;
    state.whoseTurn = p;



  pre = state.numActions;

  ret  = cardEffect(great_hall, 0, 0, 0, &state, 0, 0);

  post = state.numActions;

  if(pre != (post -1)){
    printf("Test FAILED.\n");
    fail++;
  }else{
    printf("Test PASSED.\n");
  }
  }

  printf("Great Hall Summary: %i tests failed. %i percent failure rate", fail, fail/2000);

}
